<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <button @click="list.push(99)">添加元素</button>
      <button @click="list.pop()">删除最后元素</button>
      <button @click="list.reverse()">反转</button>
      <!-- <button @click="list[0] = 999">下标修改</button> -->

      <ul>
        <li v-for="item in list">{{ item }}</li>
      </ul>
    </div>

    <script src="./vue.js"></script>
    <script>
      new Vue({
        el: '#app',
        data () {
          return {
            list: [10, 20, 30]
          }
        },
        watch: {
            // 以后到底是用普通还是深度？
            // 先用普通的发现不行再用深度
            // 如果是对象属性的改变，就要用深度侦听
            // 没设计到对象属性改变可以用普通
            list () {
                console.log('数组改变了')
            }
        }
      })
    </script>
  </body>
</html>
